
package vu.cs.heuristieken;

import java.util.List;
import java.util.LinkedList;

public abstract class ContainerEntity extends Entity implements Cloneable {
    protected List<Placement> placements;

    public ContainerEntity(Size size) {
        super(size);
        this.placements = new LinkedList<Placement>();
    }

    public void addPlacement(Placement placement) {
        this.placements.add(placement);
    }

    public List<Placement> getPlacements() {
        return this.placements;
    }

    public int getValue() {
        int totalValue = 0;
        for(Placement placement : this.placements) {
            totalValue += placement.getValue();
        }
        return totalValue;
    }

    public ContainerEntity clone() 
        throws CloneNotSupportedException {
        ContainerEntity clone = (ContainerEntity) super.clone();

        clone.placements = new LinkedList<Placement>();
        for(Placement placement : this.placements) {
            clone.addPlacement(placement.clone());
        }
        return clone;
    }
}
